import Layout from '@/layout/index'
import ParentView from '@/components/ParentView'
import InnerLink from '@/layout/components/InnerLink'
import SystemRoutes from '@/module/system/router/index';
import NoticeRoutes from '@/module/notice/router/index';
import DiskRoutes from '@/module/disk/router/index';
import CmsRoutes from '@/module/cms/router/index';
import DefaultRoutes from '@/module/default/router/index';
import CustomerRoutes from '@/views/router/index';
const router = defineStore(
    'router', {
    state: () => ({
        // 侧边栏路由
        sidebarRouters: [],
        // 基础路由配置
        systemRoutes: SystemRoutes(),
        noticeRoutes: NoticeRoutes(),
        diskRoutes: DiskRoutes(),
        cmsRoutes: CmsRoutes(),
        defaultRoutes: DefaultRoutes(),
        customerRoutes: CustomerRoutes(),
    }),
    actions: {
        setSidebarRouters(routes) {
            this.sidebarRouters = routes
        },
        // 构建路由
        buildRoutes() {
            let lastRoutes = [
                ...this.customerRoutes,
                ...this.defaultRoutes, 
                ...this.systemRoutes, 
                ...this.noticeRoutes, 
                ...this.cmsRoutes, 
                ...this.diskRoutes
            ];
            this.setSidebarRouters(lastRoutes);
            return new Promise(function (resolve, reject) {
                resolve(lastRoutes)
            })
        }
    }
})

export default router